package pro.softzhang.algo.lc1000;

import pro.softzhang.algo.flag.theme.TMathArith;

/**
 *
 */
@TMathArith
public class LC1010_PairsOfSongsWithTotalDurationsDivisibleBy60 {
    public static void main(String[] args) {

    }

    /**
     * (a + b) % 60 = 0
     * (a % 60 + b % 60) % 60 = 0
     * https://leetcode.cn/problems/pairs-of-songs-with-total-durations-divisible-by-60/solution/liang-shu-zhi-he-de-ben-zhi-shi-shi-yao-bd0r1/
     */
    static
    class Solution {
        public int numPairsDivisibleBy60(int[] time) {
            int[] modTime = new int[60];
            int pairs = 0;
            for (int t : time) {
                pairs += modTime[(60 - t % 60) % 60];
                modTime[t % 60]++;
            }
            return pairs;
        }
    }
}
